clear all

%for every subject, get the average had v did activation in each significant ROI from
%the group-level had v did t-test.

subs=[2,3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,19,20,22,23,24,25,26,27,28,29,30,31,32,33,34,35,26,27,29,40];
size(subs)

%number of ROIs in mask
%num_ROIs=14;
num_ROIs=26

for cursub=1:length(subs)

    if subs(cursub)<10
        s=['0',num2str(subs(cursub))]
    else s=num2str(subs(cursub))
    end

    for curroi=1:num_ROIs %for every ROI in the mask
        r=num2str(curroi)
        
        %get the average for this subject's activation in the current ROI from the mask
        %output results to a text file
        unix(sprintf(['3dmaskave -mask hadvdid_voxp.0001_corrp.01_mask+tlrc -quiet -mrange ',r,' ',r,' '...
            'individual_subj_data/desisl_',s,'_hadvdid_univ+tlrc > temp.txt']))
    
        %open that text file
        fid=fopen('temp.txt');
        %scan it into matlab
        fulldata(cursub,curroi)=fscanf(fid,'%f')
    
    end
end

save hadvdid_fulldata_voxp001_corrp01.mat fulldata

